# Maintainer: Sebastian Ehlert <awvwgk@disroot.org>

_pyname=FORD
_realname=ford
pkgbase=mingw-w64-python-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-python-${_realname}")
pkgver=6.1.17
pkgrel=1
pkgdesc="FORD, standing for FORtran Documenter, is an automatic documentation generator for modern Fortran programs (mingw-w64)"
url="https://github.com/Fortran-FOSS-Programmers/ford"
license=("GPL-3.0-or-later")
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clang32' 'clangarm64')
depends=("${MINGW_PACKAGE_PREFIX}-python"
         "${MINGW_PACKAGE_PREFIX}-python-beautifulsoup4"
         "${MINGW_PACKAGE_PREFIX}-python-graphviz"
         "${MINGW_PACKAGE_PREFIX}-python-jinja"
         "${MINGW_PACKAGE_PREFIX}-python-markdown"
         "${MINGW_PACKAGE_PREFIX}-python-markdown-include"
         "${MINGW_PACKAGE_PREFIX}-python-markdown-math"
         "${MINGW_PACKAGE_PREFIX}-python-pygments"
         "${MINGW_PACKAGE_PREFIX}-python-toposort"
         "${MINGW_PACKAGE_PREFIX}-python-tqdm")
makedepends=("${MINGW_PACKAGE_PREFIX}-python-build"
             "${MINGW_PACKAGE_PREFIX}-python-installer"
             "${MINGW_PACKAGE_PREFIX}-python-setuptools"
             "${MINGW_PACKAGE_PREFIX}-python-setuptools-scm"
             "${MINGW_PACKAGE_PREFIX}-python-setuptools-scm-git-archive"
             "${MINGW_PACKAGE_PREFIX}-python-wheel")
options=(!strip)
source=("https://pypi.org/packages/source/${_pyname::1}/${_pyname}/${_pyname}-${pkgver}.tar.gz")
sha256sums=('10f8cc19517ea6b8308251e59286a793c9bc47098c33da3528aca16a08143908')

prepare() {
  cd "${srcdir}"/${_realname}-${pkgver}
  sed -i -e 's|~=|>=|' setup.cfg

  cd "${srcdir}"
  rm -rf python-build-${MSYSTEM} | true
  cp -r "${_realname}-${pkgver}" "python-build-${MSYSTEM}"
}

build() {
  cd "${srcdir}/python-build-${MSYSTEM}"

  ${MINGW_PREFIX}/bin/python -m build --wheel --skip-dependency-check --no-isolation
}

package() {
  cd "${srcdir}/python-build-${MSYSTEM}"

  MSYS2_ARG_CONV_EXCL="--prefix=" \
    ${MINGW_PREFIX}/bin/python -m installer --prefix=${MINGW_PREFIX} \
    --destdir="${pkgdir}" dist/*.whl
}
